home *** CD-ROM | disk | FTP | other *** search
/ VRML Browsing & Building Cyberspace / VRML - Browsing and Building Cyberspace.iso / examples / 22.wrl < prev    next >
Text File  |  1995-06-29  |  4KB  |  124 lines

  1. #VRML V1.0 ascii
  2.  
  3. # Example twenty-two - We texture map the Earth with its surface, using a URL
  4.  
  5. # Here comes the Sun
  6. # The Separator node groups everything within it together
  7. DEF SOLAR_SYSTEM Separator {
  8.  
  9.     # The material will effect all subsequent nodes
  10.     # The sun is yellow, isn't it?  Additive color means red + green = yellow
  11.     # We're switching to emissive color because the Sun gives off light.
  12.     Material {
  13.         emissiveColor 1 1 0        # The Sun emits lots of yellow light
  14.     }
  15.  
  16.     # We'll make the Sun shine here
  17.     # A PointLight shines equally in all directions, like the Sun does.
  18.     DEF SUNLIGHT PointLight {
  19.         intensity 1        # The Sun is way bright
  20.         color 1 1 0.9   # Sunlight is basically white, even though the Sun is yellow.
  21.     }
  22.  
  23.     # The WWWAnchor node is a group node
  24.     # This means that all objects within it are linked with the anchor's URL
  25.     # We want to link the Sun, so the Sun's Sphere node goes inside of it.
  26.     # Using the description field, we provide context for the user
  27.     # The DEF node attaches the name "SUN" to the WWWAnchor group
  28.     DEF SUN WWWAnchor {
  29.         name "http://www.w3.org/" # The root URL of the World Wide Web
  30.         description "A link from the Sun to W3.ORG" # Decriptive text
  31.  
  32.         Sphere {
  33.             radius 10
  34.         }
  35.     }
  36.  
  37.     # We place the Earth within it's own Separator
  38.     # To keep everything good and isolated
  39.     Separator {
  40.  
  41.         # Let's move things out of the way here
  42.         Transform {
  43.             translation 0 20 20
  44.         }
  45.  
  46.         # Color the Earth blue, and make it absorb light
  47.         # But also make it a reflective, like water
  48.         DEF EARTH_MATERIAL Material {
  49.             diffuseColor 0 0 1 # Big blue marble
  50.             specularColor 0.9 0.9 0.9 # And a little more shiny
  51.             shininess 0.9 # Water is rather shiny
  52.         }
  53.  
  54.         # Here's where we specify the texture map
  55.         # Instead of a local RGB file, we access one across the Web
  56.         Texture2 {
  57.             filename "http://hyperreal.com/~mpesce/WORLDMAP.RGB"
  58.         }
  59.  
  60.         # The WWWAnchor node is a group node
  61.         # This means that all objects within it are linked with the anchor's URL
  62.         # We want to link the Earth, so the Earth's Sphere node goes inside of it.
  63.         # Using the description field, we provide context for the user
  64.         # The DEF node attaches the name "Earth" to the WWWAnchor node
  65.         DEF EARTH WWWAnchor {
  66.             name "http://hyperreal.com/~mpesce/book/examples/second.wrl" # Another world
  67.             description "A link to another world" # Decriptive text
  68.  
  69.             # Finally, create the earth
  70.             Sphere {
  71.                 radius 2    # Little Earth
  72.             }
  73.         }
  74.  
  75.         # The Moon gets its own Separator
  76.         # Because we really do keep everything separate
  77.         Separator {
  78.  
  79.             # The Moon is just outside the Earth
  80.             Transform {
  81.                 translation 4 4 0
  82.             }
  83.  
  84.             # Color the Moon grey, make it absorb light
  85.             # It's a little shiny, but not much
  86.             Material {
  87.                 diffuseColor 0.7 0.7 0.7
  88.                 shininess 0.3
  89.             }
  90.  
  91.             # This is a sample texture map
  92.             # Just to show how it all works.
  93.             # Using it, you'll get a 2 x 4 image
  94.             # It's in black/gray/white to make it look like a faux lunar surface
  95.             Texture2 {
  96.                 # Define a 4 x 4 pixel texture map using RGB values
  97.                 image 4 4 3 
  98.  
  99.                 # Here's the map, from lower left to upper right
  100.                 0xC0C0C0 0x808080 0xFFFFFF 0x404040 # Bottom row
  101.                 0x808080 0x202020 0x808080 0xC0C0C0 # Lower Middle Row
  102.                 0x202020 0x808080 0xFFFFFF 0x808080 # Upper Middle Row
  103.                 0x808080 0xC0C0C0 0x808080 0x202020 # Upper Row
  104.             }
  105.  
  106.             # The WWWAnchor node is a group node
  107.             # This means that all objects within it are linked with the anchor's URL
  108.             # We want to link the Moon, so the Moon's Sphere node goes inside of it.
  109.             # Using the description field, we provide context for the user
  110.             # The DEF node attaches the name "Moon" to the WWWAnchor node
  111.             DEF Moon WWWAnchor {
  112.                 name "http://www.cyborganic.com:80/People/paul/The_new_dogs/pescewrd.au"
  113.                 description "Sounds from a talk about VRML"
  114.  
  115.                 # And now, create the Moon
  116.                 Sphere {
  117.                     radius 1    # Tiny Moon
  118.                 }
  119.             }
  120.         }
  121.     }
  122. }
  123.  
  124.